package com.quad.innovators.salesease.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.annotation.JsonValue;
import com.quad.innovators.salesease.exception.BusinessException;

import java.util.HashMap;
import java.util.Map;

import lombok.Getter;

/**
 * @author : shanshan.li
 * @createTime : 2025/4/7 12:03
 * @Version : 1.0 
 */
@Getter
public enum VehicleBringExamineEnum {
    UNTESTED(1, "未校验"),
    INCONSISTENCY(2, "不一致"),
    CONSISTENCY(3, "完全一致");

    private final int code;
    private final String description;

    VehicleBringExamineEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    static final Map<Integer, VehicleBringExamineEnum> map = new HashMap<>();

    static {
        VehicleBringExamineEnum[] values = values();
        for (VehicleBringExamineEnum vehicleBringExamineEnum : values) {
            map.put(vehicleBringExamineEnum.code, vehicleBringExamineEnum);
        }
    }

    public static VehicleBringExamineEnum useCodeGetEnum(Integer code) {
        VehicleBringExamineEnum vehicleBringExamineEnum = map.getOrDefault(code, null);
        if (ObjectUtils.isNull(vehicleBringExamineEnum)) {
            throw BusinessException.resultCode(ResultCode.NOT_FOUND);
        }
        return vehicleBringExamineEnum;
    }
}
